package day05;

import java.util.Arrays;
import java.util.Random;

public class Day05Text {
    public static void main(String[] args) {
        Random rand = new Random();
        //1.
        /*for (int i=1;i<=9;i++){
            for (int j=1;j<=i;j++){
                System.out.print(j+"*"+i+"="+i*j+"\t");
            }
            System.out.println();
        }*/
        //2.
        /*int[] a=new int[4];
        a = new int[]{20,30};
        int[] arr=new int[10];
        for (int i=0;i<arr.length;i++){
            arr[i]= rand.nextInt(100);
            System.out.println(arr[i]);
        }
        int [] b=new int[10];
        System.arraycopy(arr,2,b,3,5);
        int []c=Arrays.copyOf(arr,5);

         */
        //3.
        /*int[] arr=new int[10];
        for (int i=0;i<arr.length;i++){
            arr[i]= rand.nextInt(100);
            System.out.println(arr[i]);
        }
        int max = arr[0];
        for (int i= 0;i<arr.length;i++){
            if (arr[i]>max){
                max=arr[i];
            }
        }
        System.out.println("最大值是："+max);

         */
        //4.
        /*int[] arr=new int[10];
        for (int i=0;i<arr.length;i++){
            arr[i]= rand.nextInt(100);
            System.out.println(arr[i]);
        }
        System.out.println("升序：");
        Arrays.sort(arr);
        for (int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }

         */
        //扩展
        //1.
        /*int sum=0;
        for (int i=0;i<=100;i++){
            if (i%2==0) {
                sum = sum + i;
            }
        }
        System.out.println(sum);
         */
        //2.
        /*int h=1;
        for (int i=8;i>0;i--){
            h=h*i;
        }
        System.out.println(h);
         */
        //3.
        /*String str ="*";
        System.out.println(str);
        for (int i=1;i<6;i++){
            str =str + "**";
            System.out.println(str);
        }
         */
        //4.
        int [] arr=new int[10];
        for (int i=0;i<arr.length;i++){
            arr[i]= rand.nextInt(100);
            //System.out.println(arr[i]);
        }
        Arrays.sort(arr);
        System.out.println("升序:");
        for (int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }
        int max=arr[0];
        for (int i=0;i<arr.length;i++){
            if (arr[i]>max) {
                max = arr[i];
            }
        }
        System.out.println("最大值是"+max);

        int min=arr[0];
        for (int i=0;i<arr.length;i++){
            if (arr[i]<min){
                min=arr[i];
            }
        }
        System.out.println("最小值是"+min);



    }
}
